package com.lljjcoder.citypickerview.model;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

public class CityModel implements Parcelable {
	private String name;
	private ArrayList<DistrictModel> districtList;
	
	public CityModel() {
		super();
	}

	public CityModel(String name, ArrayList<DistrictModel> districtList) {
		super();
		this.name = name;
		this.districtList = districtList;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<DistrictModel> getDistrictList() {
		return districtList;
	}

	public void setDistrictList(ArrayList<DistrictModel> districtList) {
		this.districtList = districtList;
	}

	@Override
	public String toString() {
		return "CityModel [name=" + name + ", districtList=" + districtList
				+ "]";
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(this.name);
		dest.writeList(this.districtList);
	}

	protected CityModel(Parcel in) {
		this.name = in.readString();
		this.districtList = new ArrayList<DistrictModel>();
		in.readList(this.districtList, DistrictModel.class.getClassLoader());
	}

	public static final Parcelable.Creator<CityModel> CREATOR = new Parcelable.Creator<CityModel>() {
		@Override
		public CityModel createFromParcel(Parcel source) {
			return new CityModel(source);
		}

		@Override
		public CityModel[] newArray(int size) {
			return new CityModel[size];
		}
	};
}
